<template>
	
	
	<view class="flex flex-column" style="background-color: #f0f0f0;">
		
		<view class="flex align-center justify-center" style="width: 300rpx; height: 100rpx;">
			<button style="font-size: 35rpx;" @click="newPet">新增宠物</button>
		</view>
		
		<view class="flex align-center justify-center" style="width:750rpx">
			<view class="flex flex-column" style="width: 710rpx; border-radius: 20rpx; background-color: #f0f0f0;">
				<view v-for="(item, index) in mypetsList" :key="index" @click="openPet(item.id)">
					<view class="flex" style="background-color: white; border-radius: 20rpx;">
						<image src="https://www.dogeman.studio/public/uploads/static/centers/center-demo.jpg" style="height: 250rpx; width: 250rpx; border-radius: 20rpx; margin-left: 15rpx; margin-top: 15rpx; margin-bottom: 15rpx;"></image>
						
						<view class="flex flex-column">
							<text style="font-weight: bold; font-size: 45rpx; margin-left: 30rpx; margin-top: 15rpx;">{{item.animalName}}</text>
							<text style="margin-left: 30rpx; font-size: 30rpx;">编号: {{item.id}}</text>
							<view class="flex" style="margin-left: 30rpx; margin-top: 35rpx;">
								<view v-if="item.sterilized === 1" class="flex align-center justify-center pl-1 pr-1 my-2" style="border-radius: 15rpx; background-color: chocolate; margin-left: 5rpx; margin-right: 5rpx;">
									<text style="font-size: 27rpx; color: white; font-weight: bold;">已绝育</text>
								</view>
								
								<view v-if="item.immune === 1" class="flex align-center justify-center pl-1 pr-1 my-2" style="border-radius: 15rpx; background-color: chocolate; margin-left: 5rpx; margin-right: 5rpx;">
									<text style="font-size: 27rpx; color: white; font-weight: bold;">已免疫</text>
								</view>
								
								<view v-if="item.parasite === 1" class="flex align-center justify-center pl-1 pr-1 my-2" style="border-radius: 15rpx; background-color: chocolate; margin-left: 5rpx; margin-right: 5rpx;">
									<text style="font-size: 27rpx; color: white; font-weight: bold;">已驱虫</text>
								</view>
								
							</view>
						</view>
						
					</view>
					<view style="height: 20rpx; background-color: #f0f0f0; width: 750rpx;"></view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	// const demo2 = [{
	// 				petid: 'adhsbxbciuhs',
	// 				petname: '小花',
	// 			},{
	// 				petid: 'adhsbxbcxuhs',
	// 				petname: '绿色',
	// 			},{
	// 				petid: 'adhsbxbexuhs',
	// 				petname: '叶子',
	// 			}];
	export default {
		data() {
			return {
				mypetsList: []
			}
		},
		onLoad() {
			this.getmypetsData();
		},
		methods: {
			newPet(){
				uni.navigateTo({
					url: '../add-petinfo/add-petinfo'
				})
			},
			openPet(id){
				uni.navigateTo({
					url: '../edit-petinfo/edit-petinfo?id='+id
				})
			},
			getmypetsData(){
				return this.$H.get('/rescue_station/byUserIdAni/'+this.$store.state.user.id).then(res=>{
					this.mypetsList = res
					console.log(this.mypetsList)
					// console.log(this.centerInfo)
				}).catch(err=>{
				})
				
				
				// this.mypetsList = demo2;
			}
		}
	}
</script>

<style>

</style>
